<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../docs-assets/ico/favicon.png">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="../dist/css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../dsit/css/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <div class="container">

      <div class="form-signin" >
        <h2 class="form-signin-heading">Enregistrement</h2>
		<input type="text" id = "signup-username" class="form-control" placeholder="Username" required autofocus>
        <input type="password" id = "signup-password" class="form-control" placeholder="Password" required>
		<input type="text" id = "signup-mail" class="form-control" placeholder="Email address" required></br>
		<p>Type de compte:</p>
		<label class="checkbox">
          <input type="checkbox" value="admin">Intendant UPMC
        </label>
		<label class="checkbox">
          <input type="checkbox" value="bde"> BDE ou Association
        </label>
		<label class="checkbox">
          <input type="checkbox" value="commercant"> Commerçant
        </label>

		
        <!--<label class="checkbox">
          <input type="checkbox" value="remember-me"> Remember me
        </label>-->
        <button id = "button" class="btn btn-lg btn-primary btn-block" >Sign in</button>
      </div></br>
		
	<div id="redirect" hidden>
		<p>
			<h1>REDIRECTION DANS 5 SECONDES !</h1>
		</p>
	</div>
    </div> <!-- /container -->
	<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
    <script src="../js/underscore-1.1.6.js"></script>
	<script src="http://www.parsecdn.com/js/parse-1.2.15.min.js"></script>
	<script>
	
	$( document ).ready(function() {
		function getValueSelected(){
					var entries = document.getElementsByTagName("input");
					var i=0;
					var idValue="";
					for(i=0;i<entries.length;i++){
						if(entries[i].checked == true){
							idValue=entries[i].value;
						}
					}
					if(idValue != ""){
						return idValue;
					}
					else{
						return "";
					}
				 }
			 
		Parse.$ = jQuery;
		Parse.initialize("lken7qlOOU6DnGkQddYiIIVTTGBVGt8cHsTh0mN6", "lVOSFDfYALex78xE7WdpLadiZl61hUe1VrbnLA73");
			$("#button").click(function(){
			  var username = $("#signup-username").val();
			  var password = $("#signup-password").val();
			  var email = $("#signup-mail").val();
			  var account = getValueSelected();
				var user = new Parse.User();
				user.set("username", username);
				user.set("password", password);
				user.set("email", email);
				user.set("account",account);
				 
				user.signUp(null, {
				  success: function(user) {
				  alert("Succès");
				  $("#redirect").show();
				  
				  
				  
				  
				  
				  
					window.setTimeout("location=('../index.html');",0);
				},
				
				error: function(user, error) {
				  alert("enregistrement échoué");
				}
				});
				
				

				
				
				
				
				
			  /*Parse.User.signUp(username, password,{ ACL: new Parse.ACL() },{
				success: function(user) {
				  alert("enregistrement avec succès");
				  $("#redirect").show();
					window.setTimeout("location=('../index2.html');",5000);
				},

				error: function(user, error) {
				  alert("enregistrement échoué");
				}
			  });*/

			  //$(".signup-form button").attr("disabled", "disabled");
			 });
	});
	</script>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
  </body>
</html>
